package mapper;

import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import pojo.Category;

public interface CategoryMapper {

    @Select("select * from category where category_id = #{id}")
    @Results(id = "categoryMap", value = {
            @Result(id = true, column = "category_id", property = "id"),
            @Result(column = "category_typename", property = "typeName"),
            @Result(column = "product_id", property = "productList",
//                    属性就是本类的属性，但是列来自另一个表
                    many = @Many(select = "mapper.ProductMapper.findProductById"))
    })
    public Category findById(int id);

}
